define(['./config'], () => {
    class Login {
        constructor() {
            this.init()
        }
        init() {
           
            this.bindHtml()
            this.register()
           
        }
        register() {
           
            let reg1 = new RegExp('^[a-zA-Z0-9_-]{4,16}$')
            $(".input-userName").blur(() => {
               
                let res = reg1.test($(".input-userName").val())
                console.log(1);
               
                if (!res) {
                    console.log('手机号不存在')
                   
                }
            });

            let reg2 = new RegExp('^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$')
            $(".text-input-phone").blur(() => {
                let res = reg2.test($(".text-input-phone").val())
                if (!res) {
                    console.log('手机号不存在')
                }
            });
            let reg3 = new RegExp('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]{6,}$')
            $(".text-input-password").blur(() => {
                let res = reg3.test($(".text-input-password").val())
               
                if (!res) {
                    console.log('密码不合适')
                   
                }
            });

            let username = $(".input-userName").val()
            let password = $(".text-input-password").val()
            let obj = {
                username,
                password
            }
          
                return obj
        
            

        }
        bindHtml() {
            $('body')[0].addEventListener('click', (e) => {
               
                let target = e.target
                if (target.className === 'pass-button') {
                    let obj = this.register()
                    console.log();
                  
                        localStorage.setItem('info', JSON.stringify(obj))
                        alert('注册成功')
                        location.href="http://127.0.0.1:2113/html/login2.html"
                       
                    

                   
                    e.preventDefault()

                }
            },false)

        }

    }
    return Login
})